#ifndef CMD_H
#define CMD_H

#include <QPair>

#include "gamemap.h"

class Move
{
    int _dx, _dy;
    int _nbr;
    int _ax, _ay;
    QPoint _finalDest;

public :
    Move(int rw1, int cl1, int nbr, int rw2, int cl2, QPoint final = QPoint());

    QPoint start()     {return QPoint(_dx, _dy);}
    int  strenght()             {return _nbr;}
    void setStrenght(int str)   {_nbr = str;}
    QPoint dest()      {return QPoint(_ax, _ay);}

    bool isLegal(GameMap& map);
    QPoint finalDest() { return _finalDest;}
};

class Cmd
{
protected:
    char _cmd[4];

public:
    Cmd(const char *cmd);

    virtual QByteArray toBinary() = 0;
    virtual bool isValid(GameMap& map) = 0;
};

class MoveCmd : public Cmd
{
    QList<Move> _moveList;

public :
    MoveCmd(Move m1);
    MoveCmd(Move m1, Move m2);
    MoveCmd(Move m1, Move m2, Move m3);

    QByteArray toBinary();
    bool isValid(GameMap& map);
    QList<Move> listMoves() { return _moveList; }
};

class AtkCmd : public Cmd
{
    int target_row;
    int target_col;

public :
    AtkCmd(int rw, int cl);

    QByteArray toBinary();
    bool isValid(GameMap& map);
};

#endif // CMD_H
